package com.asiainfo.complier.editor;

import java.awt.Point;
import java.awt.event.MouseEvent;

import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;

import com.asiainfo.complier.common.OutLineInfo;

public class ToolTipList extends JTree {

	/**
	 * ToolTipList
	 */
	private static final long serialVersionUID = -7352799047922779848L;

	public String getToolTipText(MouseEvent event) {
		Point p = event.getPoint();

		// int location = locationToIndex(p);
		TreePath path = getPathForLocation(p.x, p.y);
		if (path != null) {
			DefaultMutableTreeNode node = (DefaultMutableTreeNode) path
					.getLastPathComponent();//
			if (node != null) {
				OutLineInfo key = (OutLineInfo) node.getUserObject();// getModel().getElementAt(location);
				String tip = key.getMethodName();
				if (key.getReturnType() != null) {
					tip += ":" + key.getReturnType();
				}
				return tip;
			}
		}
		return "";
	}

}
